{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cdb70ac7-ec99-40cc-b920-f276a555d77b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import stockstats \n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c4fcf3bb-be79-43b6-a2f5-8646c3047d99",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('datagen/data/000001.XSHE_平安银行.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7dd307c7-aa3b-42df-ab64-e688a517ff10",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>high</th>\n",
       "      <th>volume</th>\n",
       "      <th>money</th>\n",
       "      <th>name</th>\n",
       "      <th>code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2005-01-04</td>\n",
       "      <td>1.47</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.47</td>\n",
       "      <td>7867519.0</td>\n",
       "      <td>1.146560e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2005-01-05</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.42</td>\n",
       "      <td>1.47</td>\n",
       "      <td>14396761.0</td>\n",
       "      <td>2.071856e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2005-01-06</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.44</td>\n",
       "      <td>1.47</td>\n",
       "      <td>11913717.0</td>\n",
       "      <td>1.733384e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2005-01-07</td>\n",
       "      <td>1.47</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.48</td>\n",
       "      <td>8427452.0</td>\n",
       "      <td>1.230285e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2005-01-10</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.47</td>\n",
       "      <td>1.43</td>\n",
       "      <td>1.47</td>\n",
       "      <td>11760203.0</td>\n",
       "      <td>1.711150e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4022</th>\n",
       "      <td>2021-07-22</td>\n",
       "      <td>20.45</td>\n",
       "      <td>20.38</td>\n",
       "      <td>20.24</td>\n",
       "      <td>20.66</td>\n",
       "      <td>86864809.0</td>\n",
       "      <td>1.773999e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4023</th>\n",
       "      <td>2021-07-23</td>\n",
       "      <td>20.38</td>\n",
       "      <td>20.10</td>\n",
       "      <td>20.00</td>\n",
       "      <td>20.38</td>\n",
       "      <td>72740433.0</td>\n",
       "      <td>1.461468e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4024</th>\n",
       "      <td>2021-07-26</td>\n",
       "      <td>19.96</td>\n",
       "      <td>18.80</td>\n",
       "      <td>18.43</td>\n",
       "      <td>19.99</td>\n",
       "      <td>145130394.0</td>\n",
       "      <td>2.770237e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4025</th>\n",
       "      <td>2021-07-27</td>\n",
       "      <td>18.87</td>\n",
       "      <td>17.76</td>\n",
       "      <td>17.60</td>\n",
       "      <td>18.99</td>\n",
       "      <td>135755148.0</td>\n",
       "      <td>2.461708e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4026</th>\n",
       "      <td>2021-07-28</td>\n",
       "      <td>17.85</td>\n",
       "      <td>17.75</td>\n",
       "      <td>17.68</td>\n",
       "      <td>18.07</td>\n",
       "      <td>106299421.0</td>\n",
       "      <td>1.898563e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4027 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            date   open  close    low   high       volume         money  name  \\\n",
       "0     2005-01-04   1.47   1.46   1.45   1.47    7867519.0  1.146560e+07  平安银行   \n",
       "1     2005-01-05   1.46   1.45   1.42   1.47   14396761.0  2.071856e+07  平安银行   \n",
       "2     2005-01-06   1.45   1.46   1.44   1.47   11913717.0  1.733384e+07  平安银行   \n",
       "3     2005-01-07   1.47   1.46   1.45   1.48    8427452.0  1.230285e+07  平安银行   \n",
       "4     2005-01-10   1.46   1.47   1.43   1.47   11760203.0  1.711150e+07  平安银行   \n",
       "...          ...    ...    ...    ...    ...          ...           ...   ...   \n",
       "4022  2021-07-22  20.45  20.38  20.24  20.66   86864809.0  1.773999e+09  平安银行   \n",
       "4023  2021-07-23  20.38  20.10  20.00  20.38   72740433.0  1.461468e+09  平安银行   \n",
       "4024  2021-07-26  19.96  18.80  18.43  19.99  145130394.0  2.770237e+09  平安银行   \n",
       "4025  2021-07-27  18.87  17.76  17.60  18.99  135755148.0  2.461708e+09  平安银行   \n",
       "4026  2021-07-28  17.85  17.75  17.68  18.07  106299421.0  1.898563e+09  平安银行   \n",
       "\n",
       "             code  \n",
       "0     000001.XSHE  \n",
       "1     000001.XSHE  \n",
       "2     000001.XSHE  \n",
       "3     000001.XSHE  \n",
       "4     000001.XSHE  \n",
       "...           ...  \n",
       "4022  000001.XSHE  \n",
       "4023  000001.XSHE  \n",
       "4024  000001.XSHE  \n",
       "4025  000001.XSHE  \n",
       "4026  000001.XSHE  \n",
       "\n",
       "[4027 rows x 9 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "91fe35bf-2abd-497a-a29c-e8b778f09be8",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock = stockstats.StockDataFrame.retype(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9c492629-696e-45b0-8ecb-b3c9a7db1e7a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>high</th>\n",
       "      <th>volume</th>\n",
       "      <th>money</th>\n",
       "      <th>name</th>\n",
       "      <th>code</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2005-01-04</th>\n",
       "      <td>1.47</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.47</td>\n",
       "      <td>7867519.0</td>\n",
       "      <td>1.146560e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005-01-05</th>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.42</td>\n",
       "      <td>1.47</td>\n",
       "      <td>14396761.0</td>\n",
       "      <td>2.071856e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005-01-06</th>\n",
       "      <td>1.45</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.44</td>\n",
       "      <td>1.47</td>\n",
       "      <td>11913717.0</td>\n",
       "      <td>1.733384e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005-01-07</th>\n",
       "      <td>1.47</td>\n",
       "      <td>1.46</td>\n",
       "      <td>1.45</td>\n",
       "      <td>1.48</td>\n",
       "      <td>8427452.0</td>\n",
       "      <td>1.230285e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005-01-10</th>\n",
       "      <td>1.46</td>\n",
       "      <td>1.47</td>\n",
       "      <td>1.43</td>\n",
       "      <td>1.47</td>\n",
       "      <td>11760203.0</td>\n",
       "      <td>1.711150e+07</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-22</th>\n",
       "      <td>20.45</td>\n",
       "      <td>20.38</td>\n",
       "      <td>20.24</td>\n",
       "      <td>20.66</td>\n",
       "      <td>86864809.0</td>\n",
       "      <td>1.773999e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-23</th>\n",
       "      <td>20.38</td>\n",
       "      <td>20.10</td>\n",
       "      <td>20.00</td>\n",
       "      <td>20.38</td>\n",
       "      <td>72740433.0</td>\n",
       "      <td>1.461468e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-26</th>\n",
       "      <td>19.96</td>\n",
       "      <td>18.80</td>\n",
       "      <td>18.43</td>\n",
       "      <td>19.99</td>\n",
       "      <td>145130394.0</td>\n",
       "      <td>2.770237e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-27</th>\n",
       "      <td>18.87</td>\n",
       "      <td>17.76</td>\n",
       "      <td>17.60</td>\n",
       "      <td>18.99</td>\n",
       "      <td>135755148.0</td>\n",
       "      <td>2.461708e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-07-28</th>\n",
       "      <td>17.85</td>\n",
       "      <td>17.75</td>\n",
       "      <td>17.68</td>\n",
       "      <td>18.07</td>\n",
       "      <td>106299421.0</td>\n",
       "      <td>1.898563e+09</td>\n",
       "      <td>平安银行</td>\n",
       "      <td>000001.XSHE</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4027 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open  close    low   high       volume         money  name  \\\n",
       "date                                                                      \n",
       "2005-01-04   1.47   1.46   1.45   1.47    7867519.0  1.146560e+07  平安银行   \n",
       "2005-01-05   1.46   1.45   1.42   1.47   14396761.0  2.071856e+07  平安银行   \n",
       "2005-01-06   1.45   1.46   1.44   1.47   11913717.0  1.733384e+07  平安银行   \n",
       "2005-01-07   1.47   1.46   1.45   1.48    8427452.0  1.230285e+07  平安银行   \n",
       "2005-01-10   1.46   1.47   1.43   1.47   11760203.0  1.711150e+07  平安银行   \n",
       "...           ...    ...    ...    ...          ...           ...   ...   \n",
       "2021-07-22  20.45  20.38  20.24  20.66   86864809.0  1.773999e+09  平安银行   \n",
       "2021-07-23  20.38  20.10  20.00  20.38   72740433.0  1.461468e+09  平安银行   \n",
       "2021-07-26  19.96  18.80  18.43  19.99  145130394.0  2.770237e+09  平安银行   \n",
       "2021-07-27  18.87  17.76  17.60  18.99  135755148.0  2.461708e+09  平安银行   \n",
       "2021-07-28  17.85  17.75  17.68  18.07  106299421.0  1.898563e+09  平安银行   \n",
       "\n",
       "                   code  \n",
       "date                     \n",
       "2005-01-04  000001.XSHE  \n",
       "2005-01-05  000001.XSHE  \n",
       "2005-01-06  000001.XSHE  \n",
       "2005-01-07  000001.XSHE  \n",
       "2005-01-10  000001.XSHE  \n",
       "...                 ...  \n",
       "2021-07-22  000001.XSHE  \n",
       "2021-07-23  000001.XSHE  \n",
       "2021-07-26  000001.XSHE  \n",
       "2021-07-27  000001.XSHE  \n",
       "2021-07-28  000001.XSHE  \n",
       "\n",
       "[4027 rows x 8 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "fea57402-cf82-49c8-8602-147aef61c03d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "stockstats.StockDataFrame"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(stock)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aaf5997d-55f9-4365-8f5d-9b4529ad64dc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
